#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;

vector < int> vi(1001, 0);
vector < string> vs(1001);

int main()
{
    int n;
    char ch;
    cin >> n;
    getchar();

    for ( int i = 0; i < n; ++ i) {
        ch = getchar();
        vi[i] = ch - '0';
    }

    for ( int i = 0; i < n; ++ i) {
        int temp = ( 10 - vi[i]) % 10;
//        cout << temp << endl;
        string st;
        for ( int k = i; k < n; ++ k) {
            st += ( vi[k] + temp) % 10 + '0';
        }
        for ( int k = 0; k < i; ++ k) {
            st += ( vi[k] + temp) % 10 + '0';
        }
        vs[i] = st;
    }
    sort( vs.begin(), vs.begin() + n);
    cout << vs[0] << endl;

    return 0;
}
